package org.example.io.handler.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.apache.commons.lang3.StringUtils;
import org.example.io.protocol.packet.CreateGroupResponsePacket;
import org.example.io.util.LogUtil;

import java.util.List;

public class CreateGroupResponsePacketHandler extends SimpleChannelInboundHandler<CreateGroupResponsePacket> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, CreateGroupResponsePacket msg) throws Exception {
        StringBuffer sb = new StringBuffer("群创建成功，群里面有【");

        // 往每个channel发送消息
        List<String> userList = msg.getUserIds();

        sb.append(StringUtils.join(userList, ",") + "】");
        LogUtil.info(sb.toString());
    }
}
